package thread;

import java.util.concurrent.locks.LockSupport;

/**
 * 演示线程阻塞工具类LockSupport
 * 
 * @author YangHang
 * @Date 2019年3月26日 下午10:21:15
 *
 */
public class LockSupportDemo {

    private static class LockSupportThread implements Runnable {

        @Override
        public void run() {

            System.out.println("线程运行");
//            try {
//                Thread.sleep(5000);
//            } catch (InterruptedException e) {
//                e.printStackTrace();
//            }
            // 阻塞了，线程。
            LockSupport.park();

            System.out.println("线程运行完成");
        }

    }

    public static void main(String[] args) {

        Thread t1 = new Thread(new LockSupportThread());
        t1.start();
        LockSupport.unpark(t1);
        System.out.println("完成响应。");
    }

}